package com.wtwd.campus.receiver;


import com.wtwd.campus.utils.InjectService;

/**
 * @Author ldaoliang
 * @Date create in 15:44 2021/3/25
 * @Description
 */
public interface Receiver {

    /**
     * 解析消息
     *
     * @param data
     * @return
     */
    String parseMessage(String data);

    /**
     * 指令完成（删除） TODO 收到某条指令的回复时，如果该指令需要存储重发，则需要删除redis缓存的指令
     *
     * @param imei
     * @param key
     */
    default void completeCommand(String imei, String key) {
        InjectService.delCommand(imei, key);
    }

    /**
     * 解析设备状态
     *
     * @param deviceStatus
     * @return
     */
    default String convertDeviceStatus(String deviceStatus) {
        String status = "";
        int seq = deviceStatus.indexOf("D");
        switch (seq) {
            case 0:
                status = "M1模式";
                break;
            case 1:
                status = "M2模式";
                break;
            case 2:
                status = "M3模式";
                break;
            case 3:
                status = "已开GPS";
                break;
            case 4:
                status = "已定位";
                break;
            case 5:
                status = "静止";
                break;
            case 6:
                status = "WIFI扫描开启";
                break;
            case 7:
                status = "M4模式";
                break;
        }
        return status;
    }
}

